﻿import QtQuick 2.0
import "../components"

Item {

    id: root
    anchors.fill: parent

    property real bcgOpacity: 1
    property var bcgColor: "white"
    property int pstype: 0

    Rectangle{
        anchors.fill: parent
        opacity: bcgOpacity
        color: bcgColor
    }

    Rectangle{
        height: 320*dp
        width: 300*dp
        radius: 15*dp
        anchors.centerIn: parent
        anchors.verticalCenterOffset: -30*dp

        Column{
            y: 20*dp
            spacing: 25*dp
            anchors.fill: parent
            Image{
                height: 80
                width:  80
                source: "qrc:/picture/password_lock.png"
                anchors.horizontalCenter: parent.horizontalCenter
            }
            Text{
                text: "请输入密码"
                font.pixelSize: config.fontsize+1
                anchors.horizontalCenter: parent.horizontalCenter
            }
            LineEditor{
                id: edit_pswd
                editWidth: 260*dp
                inputEchoModel: TextInput.Password
                anchors.horizontalCenter: parent.horizontalCenter
                inputMaxLength: 20
            }
            PushButton{
                title: "确定"
                defaultMode1: true
                anchors.horizontalCenter: parent.horizontalCenter
                onReleased: {
                    if(pstype===0){
                        if(CSetUp.checkPassWord(edit_pswd.getText()) === 1){
                            root.visible = false
                            edit_pswd.setText("")
                        }else{
                            mainwindow.showToast("密码错误", 1)
                        }
                    }else if(pstype===1){
                        if(edit_pswd.getText()==="12344312"){
                            root.visible = false
                            edit_pswd.setText("")
                        }else{
                            mainwindow.showToast("密码错误", 1)
                        }
                    }


                }
            }
        }
    }
}
